package com.scs.application.modules.settlement.consts;

import com.scs.application.core.exceptions.BusinessException;
import com.scs.application.core.utils.StringUtils;

import java.util.HashMap;
import java.util.Map;
// 发票分组条件
public class InvoiceGroupType {
    //期号+品名+品规+批次+价格
    public final static String period1 ="period1";

    ////期号+品名+品规+价格
    public final  static String period2 ="period2";

    //记账单号+品名+品规+批次+价格
    public final  static String bill1 ="bill1";

    private static Map<String,String> groupMap = new HashMap<String,String>();
    static {
        //期号+品名+品规+批次+价格
        groupMap.put(period1," b.period_no,bi.material_name,bi.material_spec,bi.lot,bi.price ");

        //期号+品名+品规+价格
        groupMap.put(period2," b.period_no,bi.material_name,bi.material_spec,bi.price ");

        //记账单号+品名+品规+批次+价格
        groupMap.put(bill1," bi.bill_id,b.code,bi.material_name,bi.material_spec,bi.lot,bi.price ");
    }

    /**
     * @Description：获取分组条件
     */
    public static String getByGroupType(String groupType){
        BusinessException.throwErrorIf(StringUtils.isBlank(groupType),"参数缺失");
        BusinessException.throwErrorIf(!groupMap.containsKey(groupType),"未找到该分组条件");
        return groupMap.get(groupType);
    }
}
